;(function () {
    'use strict';
    angular.module('question',[])
        .service('QuestionService',[
            '$state',
            '$http',function ($state,$http) {
                var me = this;
                me.go_add_title = function () {
                    $state.go('question.add');
                }

                me.add = function () {
                    if (!me.new_question.title) return;

                    $http.post('/api/question/add',me.new_question)
                        .then(function () {
                            $state.go('home');
                        },function () {

                        })
                }

            }

        ])
        .controller('QuestionController',[
            '$scope',
            'QuestionService',
            function ($scope,QuestionService) {
                $scope.Question = QuestionService;
            }
        ])
})();